home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C/C++ Users Group Library 1996 July
/
C-C++ Users Group Library July 1996.iso
/
vol_300
/
329_02
/
xcxref.c
< prev
next >
Wrap
C/C++ Source or Header
|
1990-06-09
|
51KB
|
1,761 lines
/***********************************************************
XCXREF - A 'C' Concordance Utility
Version 1.0 xc - January, 1982
Version 1.0 xcxref - May, 1990
Copyright (c) 1982 by Philip N. Hisley
Philip N. Hisley
548H Jamestown Court
Edgewood, Maryland 21040
(301) 679-4606
Released for non-commercial distribution only
Converted to IBM/PC CI/C86 by David N. Smith, May/June 1983
with enhancements and Lattice compiler support in December 1983.
David N. Smith
44 Ole Musket Lane
Danbury, CT 06810
(203) 748-5934
CompuServe: 73145,153
Changes Copyright (c) 1983 by David N. Smith
Permission granted to copy for non-commercial purposes.
Version v1.0 XCXREF - May, 1990.
Program functions extended, hence the name change.
Martin D. Winnick
5301 El Arbol Drive
Carlsbad, CA 92008
(619) 431-0485
CompuServe: 71665,456
May 1990
Changes Copyright (c) 1990 by Martin D. Winnick
Permission granted to copy for non-commercial use only.
See the accompanying xcxref.doc file for program history and
all change details.
Abstract:
'XCXREF' is a cross-reference utility for 'C' programs.
Its will handle nested #include files and properly process
nested comments.
Option flags control the following features:
Usage: xcxref <filename> <flag(s)>
Flags: -e = Write program data to log file
-g = Ignore missing files
-i = Enable #include processing
-l = Generate listing only - no xref
-o <outfile> = Write output to named file
-p = Write output to line printer LPT1
-r = Cross-reference 'C' reserved words
-s = Write output to video screen
-w width = Width of output page; default = 78
max = 150
Flags MUST FOLLOW all input file names
***********************************************************/
#include "bios.h"
#include "ctype.h"
#include "direct.h"
#include "dos.h"
#include "stdio.h"
#include "stdlib.h"
#include "string.h"
#include "time.h"
#ifndef TRUE
#define TRUE 1
#define FALSE 0
#endif
#define ERROR -1
#define FF 0x0C /* formfeed */
#define FOREVER for(;;)
#define LINES_PER_PAGE 60
#define LPT1 0 /* defines LPT1 */
#define MAX_ALPHA 53 /* maximum alpha chain heads */
#define MAX_LEN 31 /* maximum identifier length */
#define MAX_REF 5 /* maximum refs per ref-block */
#define MAX_REFS_LINE 10 /* maximum refs per line */
#define MAX_WRD 5000 /* maximum number of identifiers (749) */
#define MAXCOL 78 /* right margin for listing line */
#define MAXLINE 150 /* maximum print line length. */
#define MINCOL 30 /* minimum value for -w option */
struct alpha_hdr
{
struct id_blk *alpha_top;
struct id_blk *alpha_lst;
};
struct id_blk
{
char id_name[MAX_LEN];
struct id_blk *alpha_lnk;
struct rf_blk *top_lnk;
struct rf_blk *lst_lnk;
};
struct rf_blk
{
int ref_item[MAX_REF];
int ref_cnt;
struct rf_blk *next_rfb;
};
struct alpha_hdr alpha_vector[MAX_ALPHA];
struct dosdate_t dt;
struct id_blk *id_vector[MAX_WRD];
int al_count = 0; /* number of alpha links */
int edtnum = 0; /* edit line number */
int file_level = 0; /* file level */
int hash_hits = 0; /* number of conflict hits */
int id_cnt = 0; /* number of unique identifiers */
int id_count = 0; /* number of id structs alloc. */
int linum = 0; /* line number */
int paglin = 0; /* page line counter */
int pagno = 0; /* page number */
int rf_count = 0; /* number of rf structs alloc. */
short base_row = 0; /* basic data display video row */
short maxcol = MAXCOL; /* right column for listing */
short maxrefs = MAX_REFS_LINE; /* max references per line */
short vline = 10; /* work data display video column */
short do_echo = TRUE;
short do_includes = FALSE;
short do_lprint = FALSE;
short do_numbrs = TRUE;
short do_outfile = FALSE;
short do_res_wds = FALSE;
short do_screen = FALSE;
short file_queue = FALSE;
short ignore = FALSE;
short infl_open = FALSE;
short lf_open = FALSE;
short list_only = FALSE;
short log_on = FALSE;
short prt_ref = FALSE;
short qfl_open = FALSE;
short qfirst = TRUE;
char current_file[_MAX_PATH] = { '\0' };
char glbl_file[_MAX_PATH] = { '\0' };
char list_file[_MAX_PATH] = { '\0' };
char log_file[] = { "XCXREF.LOG" };
char work_name[_MAX_PATH] = { '\0' };
/* Working file name components */
char wdrive[_MAX_DRIVE] = { '\0' };
char wdir[_MAX_DIR] = { '\0' };
char wfname[_MAX_FNAME] = { '\0' };
char wext[_MAX_EXT] = { '\0' };
/* Current default directory components */
char ddrive[_MAX_DRIVE] = { '\0' };
char ddir[_MAX_DIR] = { '\0' };
/* Alternate path name components */
char adrive1[_MAX_DRIVE] = { '\0' };
char adir1[_MAX_DIR] = { '\0' };
char adrive2[_MAX_DRIVE] = { '\0' };
char adir2[_MAX_DIR] = { '\0' };
char adrive3[_MAX_DRIVE] = { '\0' };
char adir3[_MAX_DIR] = { '\0' };
char adrive4[_MAX_DRIVE] = { '\0' };
char adir4[_MAX_DIR] = { '\0' };
char xfname[_MAX_FNAME] = { '\0' };
char xext[_MAX_EXT] = { '\0' };
char b22[] = { " " };
char *days[] = { "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" };
char emsgs[71] = { '\0' };
char pdate[] = { "Thu 05/10/90" };
char prt_line[256] = { '\0' };
char version[] = { "v1.0" };
char xcx_name[] = { "XCXREF ... " };
char xname[] = { "XCXREF.LST" };
FILE *f_list_file; /* list file */
FILE *lgfile; /* program data log file */
FILE *ofile; /* general open file */
/* function prototypes */
struct rf_blk *add_rf(struct rf_blk *adr_ptr, int adr_ref);
struct id_blk *alloc_id(char *aid_token);
struct rf_blk *alloc_rf(int arf_ref);
void chain_alpha(struct id_blk *ca_ptr, char *ca_token);
int check_for_resword(char *c_token);
void clr_scrn(short crow, short nrows);
void do_prints(int pparm);
void do_print_xrefs(void);
void echo(char c);
void echochar(char c);
int get_file_char(FILE *cfile, int *f_eof);
int get_fqueue(char *qfn);
void get_include_fileid(char *token, FILE *ifile, short parm);
int get_token(FILE *gfile, char *g_token, int *g_toklen, int *g_eoflg, char x_chr);
void list_err(int parm);
void logit(short parm);
void lprintr(char *buffer);
void new_line(void);
int openlist(char *lname);
FILE *open_rfile(void);
void pause(clock_t mcount);
void pexit(int xparm);
void print_header(void);
int proc_file(int incnum);
void put_token(char *p_token, int p_ref);
char read_file_char(FILE *rfile, int *r_eoflg, char rd_flg);
void set_csr(short vrow, short vcol);
void use_err(void);
/*************************************************************************/
int main(int p_argc, char **p_argv)
{
char *arg, **arg